package com.weishenai.Service.impl;

import com.weishenai.Entity.UserInfo;
import com.weishenai.Service.UserInfoService;
import com.weishenai.dao.UserInfoDao;
import com.weishenai.dao.impl.UserInfoDaoImpl;

import java.util.List;

/**
 * @Auther: weishenai
 * @Date: 2021/10/07/11:29
 * @Description:
 */
public class UserInfoServiceImpl implements UserInfoService {

    UserInfoDao userInfoDao;

    public UserInfoServiceImpl() {
        userInfoDao = new UserInfoDaoImpl();
    }

    @Override
    public List<UserInfo> getUserInfoList(String search, int pageSize, int pageNum) {
        return userInfoDao.getUserInfoList(search, pageSize, pageNum);
    }

    @Override
    public int getUserInfoCount() {
        return userInfoDao.getUserInfoCount();
    }

    @Override
    public int save(UserInfo userInfo) {
//        id 为空 执行insert
        if (userInfo.getId() == null) {
            return userInfoDao.insertUserInfo(userInfo);
        }
        return userInfoDao.updateUserInfo(userInfo);
    }

    @Override
    public int deleteById(String id) {
        return userInfoDao.deleteById(id);
    }
}
